package com.wu.example;


public class PerformenceUtil {

	private static final int MAX = 10;
	private static long[] nanotime = new long[MAX];

	// private static long[] time = new long[MAX];

	public static void start(int i) {
		if (i > MAX) {
			throw new RuntimeException("the number is too big than MAX");
		} else {
			nanotime[i] = System.nanoTime();
			// time[i] = System.currentTimeMillis();
		}
	}

	public static double end(int i) {
		if (i > MAX) {
			throw new RuntimeException("the number is too big than MAX");
		} else {
			if (nanotime[i] != 0) {
				// Log.d("performenceTest", (System.currentTimeMillis() -
				// time[i])
				// + "");
				return (System.nanoTime() - nanotime[i]) / 1000000;
			} else {
				throw new RuntimeException("the time[" + i + "] is not start");
			}
		}
	}
}
